<html>
<head>
    <title></title>
    <meta charset="utf-8">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no">
    <meta name="renderer" content="webkit">
    <title>站细管理系统</title>
    <link rel="stylesheet" type="text/css" href="/layuicms/layui/css/layui.css"/>
    <link rel="stylesheet" type="text/css" href="/admin/css/style.css"/>
    <link rel="stylesheet" href="/layuicms/layui_ext/dtree/dtree.css" media="all"/>
    <link rel="stylesheet" href="/layuicms/layui_ext/dtree/font/dtreefont.css" media="all"/>
    <script type="text/javascript" charset="utf-8" src="/admin/ueditor/ueditor.config.js"></script>
    <script type="text/javascript" charset="utf-8" src="/admin/ueditor/ueditor.all.js"></script>
    <script type="text/javascript" charset="utf-8" src="/admin/ueditor/lang/zh-cn/zh-cn.js"></script>
    <script type="text/javascript" src="/layuicms/layui_ext/dist/dtree.js"></script>
    <style type="text/css">
        .boxs {
            height: 100vh;
            overflow: hidden;
        }
        #edui1_iframeholder {
            overflow: hidden;
        }
        div #layui-layer2 .layui-layer layui-layer-page {
            z-index: 198910161;
        !important;
        }
    </style>
</head>

<body style="overflow: hidden;position: relative;">
<div class="boxs">
    <div class="contentBox">
        <div class="contentLeft">
            <!--<blockquote class="layui-elem-quote">
                <a href="javascript:void(0)" id="removeOrg" onclick="closeToEditByZdid()"><i class="icon-x"></i></a>
            </blockquote>-->
            <div class="tree-list" style="overflow: auto;" id="toolbarDiv">
                <span id="2" style="/* display: none; */"><b>文件标题</b></span><br>
                <span id="3" style="/* display: none; */"><b>站名</b></span><br>
                <span id="4" style="/* display: none; */"><b>公司名称</b></span><br>
                <ul id="standFileTree" class="dtree" data-id="0" style="height: auto;"></ul>
            </div>
        </div>
        <form action="" method="post" class="layui-form layui-form-pane" id="dataFrm" lay-filter="dataFrm">
            <div class="contentRight layui-row">
                <div class="layui-col-md6 oldContext">
                    <div class="old-box">
                        <div class="old-title">
                            <button type="button" class="close" aria-label="Close">
                                <span aria-hidden="true">×</span>
                            </button>
                            <button type="button" class="oldCompare">旧版</button>
                            <span>站点对比</span>
                            <select id="organizationCompare" name="organization.id" style="width:100px;!important;">
                                <option value="">请选择</option>
                                <option value="2">平塘站</option>
                                <option value="3">良江站</option>
                                <option value="4">来宾站</option>
                                <option value="5">凤凰站</option>
                                <option value="8">白山站</option>
                                <option value="9">进德站</option>
                                <option value="10">古瓦站</option>
                                <option value="11">白鹤隘站</option>
                                <option value="12">合山站</option>
                                <option value="13">黎塘站</option>
                                <option value="14">稔竹站</option>
                                <option value="15">沙江站</option>
                                <option value="16">六景站</option>
                                <option value="17">伶俐站</option>
                                <option value="18">邕宁站</option>
                                <option value="19">屯里站</option>
                                <option value="20">南宁南站</option>
                                <option value="21">沙井站</option>
                                <option value="22">南化站</option>
                                <option value="23">金鸡村站</option>
                                <option value="24">江西村站</option>
                                <option value="25">维罗站</option>
                                <option value="26">扶绥站</option>
                                <option value="27">渠黎站</option>
                                <option value="28">渠旧站</option>
                            </select>
                            <button type="button" class="bgCompare">参考编规</button>
                        </div>
                        <div id="oldContext">
                        </div>
                    </div>
                </div>
                <div class="layui-col-md6 newContext" id="newContext" style="width: 50%;!important;">
                    <div class="new-box" style="">
                        <div class="new-title">
                            <span>新版</span>
                        </div>
                        <div>
                            <div name="treeContext" id="editor" style="width:100%;height:500px;"></div>
                            <div id="bz">
                                <div id="groupBox" style="display: block;">
                                    <input type="hidden" name="nodeId" id="nodeId">
                                    <input type="hidden" name="parentId" id="parentId">
                                    <input type="hidden" name="stationId" id="stationId">
                                    <p>同步到以下车站:</p>
                                    <div class="layui-form-item" id="checkboxStation">
                                    </div>
                                    <div class="e-action">
                                        <div id="dfzd">
                                            <button type="button" class="layui-btn layui-btn-normal layui-btn-sm"
                                                    id="doSubmit">保存数据
                                            </button>
                                            <button type="button" class="layui-btn layui-btn-warm layui-btn-sm"
                                                    id="updateFileRecord">提交修改
                                            </button>
                                        </div>
                                    </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <div id="groupBoxEdit">
        <p>请选择要编辑的车站:</p>
        <div id="organizationContentEdit">
            <span class="organizationBtn organizationBtnIdEdit2">平塘站<input type="hidden" value="2"></span>
            <span class="organizationBtn organizationBtnIdEdit3">良江站<input type="hidden" value="3"></span>
            <span class="organizationBtn organizationBtnIdEdit4">来宾站<input type="hidden" value="4"></span>
            <span class="organizationBtn organizationBtnIdEdit5">凤凰站<input type="hidden" value="5"></span>
            <span class="organizationBtn organizationBtnIdEdit8">白山站<input type="hidden" value="8"></span>
            <span class="organizationBtn organizationBtnIdEdit9">进德站<input type="hidden" value="9"></span>
            <span class="organizationBtn organizationBtnIdEdit10">古瓦站<input type="hidden" value="10"></span>
            <span class="organizationBtn organizationBtnIdEdit11">白鹤隘站<input type="hidden" value="11"></span>
            <span class="organizationBtn organizationBtnIdEdit12">合山站<input type="hidden" value="12"></span>
            <span class="organizationBtn organizationBtnIdEdit13">黎塘站<input type="hidden" value="13"></span>
            <span class="organizationBtn organizationBtnIdEdit14">稔竹站<input type="hidden" value="14"></span>
            <span class="organizationBtn organizationBtnIdEdit15">沙江站<input type="hidden" value="15"></span>
            <span class="organizationBtn organizationBtnIdEdit16">六景站<input type="hidden" value="16"></span>
            <span class="organizationBtn organizationBtnIdEdit17">伶俐站<input type="hidden" value="17"></span>
            <span class="organizationBtn organizationBtnIdEdit18">邕宁站<input type="hidden" value="18"></span>
            <span class="organizationBtn organizationBtnIdEdit19">屯里站<input type="hidden" value="19"></span>
            <span class="organizationBtn organizationBtnIdEdit20">南宁南站<input type="hidden" value="20"></span>
            <span class="organizationBtn organizationBtnIdEdit21">沙井站<input type="hidden" value="21"></span>
            <span class="organizationBtn organizationBtnIdEdit22">南化站<input type="hidden" value="22"></span>
            <span class="organizationBtn organizationBtnIdEdit23">金鸡村站<input type="hidden" value="23"></span>
            <span class="organizationBtn organizationBtnIdEdit24">江西村站<input type="hidden" value="24"></span>
            <span class="organizationBtn organizationBtnIdEdit25">维罗站<input type="hidden" value="25"></span>
            <span class="organizationBtn organizationBtnIdEdit26">扶绥站<input type="hidden" value="26"></span>
            <span class="organizationBtn organizationBtnIdEdit27">渠黎站<input type="hidden" value="27"></span>
            <span class="organizationBtn organizationBtnIdEdit28">渠旧站<input type="hidden" value="28"></span>
            <span class="organizationBtn organizationBtnIdEdit29">濑湍站<input type="hidden" value="29"></span>
            <span class="organizationBtn organizationBtnIdEdit30">崇左站<input type="hidden" value="30"></span>
            <span class="organizationBtn organizationBtnIdEdit31">天西站<input type="hidden" value="31"></span>
            <span class="organizationBtn organizationBtnIdEdit32">亭亮站<input type="hidden" value="32"></span>
            <span class="organizationBtn organizationBtnIdEdit33">龙伯屯站<input type="hidden" value="33"></span>
            <span class="organizationBtn organizationBtnIdEdit34">宁明站<input type="hidden" value="34"></span>
            <span class="organizationBtn organizationBtnIdEdit35">夏石站<input type="hidden" value="35"></span>
            <span class="organizationBtn organizationBtnIdEdit36">凭祥北<input type="hidden" value="36"></span>
            <span class="organizationBtn organizationBtnIdEdit37">凭祥站<input type="hidden" value="37"></span>
            <span class="organizationBtn organizationBtnIdEdit41">小平阳站<input type="hidden" value="41"></span>
            <span class="organizationBtn organizationBtnIdEdit42">demo<input type="hidden" value="42"></span>
            <span class="organizationBtn organizationBtnIdEdit47">沧州站<input type="hidden" value="47"></span>
            <span class="organizationBtn organizationBtnIdEdit48">龙伯屯东站<input type="hidden" value="48"></span>
            <span class="organizationBtn organizationBtnIdEdit49">任丘站<input type="hidden" value="49"></span>
            <span class="organizationBtn organizationBtnIdEdit50">河间站<input type="hidden" value="50"></span>
            <span class="organizationBtn organizationBtnIdEdit51">东光站<input type="hidden" value="51"></span>
        </div>
        <div id="groupContentEdit">
            <span class="groupBtn">全站<input type="hidden" value="2"></span>
            <span class="groupBtn">来宾车间<input type="hidden" value="4"></span>
            <span class="groupBtn">黎塘<input type="hidden" value="6"></span>
            <span class="groupBtn">六景车间<input type="hidden" value="7"></span>
            <span class="groupBtn">南宁南站<input type="hidden" value="8"></span>
            <span class="groupBtn">崇左车间<input type="hidden" value="9"></span>
            <span class="groupBtn">凭祥车间<input type="hidden" value="10"></span>
        </div>
        <span class="closeGroupBoxEdit" style="">确定</span>
    </div>
</div>
<script type="text/javascript" src="/layuicms/layui/layui.js"></script>
<script type="text/javascript" src="/layuicms/layui_ext/dist/dtree.js"></script>
<script type="text/javascript">
    layui.extend({
        dtree: '/layuicms/layui_ext/dtree/dtree'   // {/}的意思即代表采用自有路径，即不跟随 base 路径
    }).use(['jquery', 'form', 'layer', 'dtree', 'layedit'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var dtree = layui.dtree;
        var layedit = layui.layedit;
        // var h=$(document).height()-400;
        var standFileTree;
        var form = layui.form;
        //创建一个编辑器  初始化富文本
        var editIndex = layedit.build('remark');
        //初始化富文本
        var ue = UE.getEditor('editor', {
            initialFrameWidth: '100%',
            initialFrameHeight: 500,
            retainOnlyLabelPasted: false,
            elementPathEnabled: false,
            //  wordCount:false,
            pasteplain: false,
            toolbars: [
                [
                    'source', //源代码
                    'undo', //撤销
                    'redo', //重做
                    'bold', //加粗
                    'preview', //预览
                    'horizontal', //分隔线
                    'removeformat', //清除格式
                    'simpleupload', //单图上传
                    'insertimage', //多图上传
                    'inserttable', //插入表格
                    'edittable', //表格属性
                    'emotion', //表情
                    'justifyleft', //居左对齐
                    'justifyright', //居右对齐
                    'justifycenter', //居中对齐
                    'justifyjustify', //两端对齐
                    'forecolor', //字体颜色
                    'fullscreen', //全屏
                    'attachment', //附件
                ]
            ],
            zIndex: 19891015
        });
        ue.ready(function () {
            ue.setHeight(500);
        });
        /*checkboxStation*/
        var stationId = $(window.parent.document).find("#stationId").val();
        $("#stationId").val(stationId);
        $.get("/station/loadAllStationSelect",{stationId:stationId},function (res) {
            var list = res.data;
            var dom = $("#checkboxStation");
            var html = '';
            $.each(list, function (index, item) {
                html += '<input type="checkbox" name="sid" title="'+item.title +'" value="'+ item.id +'">'
            });
            $(dom).append(html);
            form.render('checkbox'); //刷新select选择框渲染
        })
        var id = $(window.parent.document).find("#editId").val();
        // 初始化树
        standFileTree = dtree.render({
            elem: "#standFileTree",
            dataStyle: "layuiStyle",
            dataFormat: "list",  //配置data的风格为list
            response: {message: "msg", statusCode: 0},
            initLevel: "1",
            icon: "2",
            record: true,
            line: true,
            scroll: "#toolbarDiv",
            url: '/standFineList/loadStandFileManagerLeftJson/' + id // 使用url加载（可与data加载同时存在）
        });
        // 绑定节点点击standId
        var url = "";
        var id = "";
        dtree.on("node('standFileTree')", function (obj) {
            var json = obj.param.recordData;
            var star = JSON.parse(json);//获取对应的value
            id = star.standId;
            $("#nodeId").val(obj.param.nodeId);
            $("#parentId").val(obj.param.parentId);
            $.get("/standFile/findStandFileById/" + id, function (res) {
                $("#oldContext").html(res.data.item.remark);
            })
            $.ajax({
                type: "post",
                data: {nodeId: star.standId},
                url: "/fileManage/findStandFileTree",
                success: function (result) {
                    var ue = UE.getEditor('editor');
                    var proinfo = result.data.item.treeContext;
                    url = "/fileManage/updateStandFileById/" + star.standId;
                    if (null != proinfo) {
                        ue.ready(function () {//编辑器初始化完成再赋值
                            ue.setContent(proinfo);  //赋值给UEditor
                            ue.setHeight(500);
                        });
                    } else {
                        ue.ready(function () {//编辑器初始化完成再赋值
                            ue.setContent("");  //赋值给UEditor
                            ue.setHeight(500);
                        });
                    }
                }
            });
        });
        $("#refer").click(function () {
            $.get("/standFile/findStandFileById/" + id, function (res) {
                $("#oldContext").html(res.data.item.remark);
            })
        })
        $("#doSubmit").click(function () {
            //同步富文本和textarea里面的内容
            layedit.sync(editIndex)
            var data = $("#dataFrm").serialize();
            $.post(url, data, function (res) {
                if (res.code == 20000) {
                    /*tableIns.reload();*/
                }
                layer.msg(res.message);
                //   layer.close(mainIndex);
            })
        });
        $("#updateFileRecord").click(function () {
            //同步富文本和textarea里面的内容
            layedit.sync(editIndex)
            var data = $("#dataFrm").serialize();
            $.post("/fileManage/updateFileRecord/", data, function (res) {
                if (res.code == 20000) {
                    /*tableIns.reload();*/
                }
                layer.msg(res.message);
                //   layer.close(mainIndex);
            })
        });


        $(function () {
            /*点击选择车站 显示编辑车站层*/
            $("#showE-action").on("click", function () {
                $("#groupBoxEdit").toggle();
            });
            $("#organizationContentEdit span,#organizationContent span,#groupContentEdit .groupBtn,#groupContent .groupBtn").on("click", function () {
                $(this).toggleClass("fontColor");
            });
            /*选择编辑的车站*/
            $("#organizationContentEdit span").each(function (index, domEle) {
                $(domEle).on("click", function () {
                    var i = $(this);
                    if (i.hasClass("fontColor")) {
                        var vals = $(i).find("input").val();
                        var txt = $(i).text();
                        $("#showOrganization").append('<a href="#" class="organizationBtn organizationBtnIdEdit' + vals + '" onclick="toEditByZdid()">' + txt + '<input type="hidden" value="+"vals"+"></a>');
                    } else {
                        var vals = $(i).find("input").val();
                        $("#showOrganization").find(".organizationBtnIdEdit" + vals + "").remove();
                    }
                });
            });
            /*快速选择车间里的车站*/
            $("#groupContentEdit .groupBtn").eq(0).click(function () {
                if ($(this).hasClass("fontColor")) {
                    $("#organizationContentEdit .organizationBtn").addClass("fontColor");
                    $("#organizationContentEdit span").each(function (index, domEle) {
                        var vals = $(domEle).find("input").val();
                        var txt = $(domEle).text();
                        var span1 = '<a href="#" class="organizationBtn organizationBtnIdEdit' + vals + '" onclick="toEditByZdid()">' + txt + '<input type="hidden" value="+"vals"+"></a>';
                        $("#showOrganization").append(span1);
                    });

                } else {
                    $("#organizationContentEdit .organizationBtn").removeClass("fontColor");
                    $("#showOrganization .organizationBtn").remove();
                }

            });

            /*同步到车次*/
            $("#organizationContent span").each(function (index, domEle) {
                $(domEle).on("click", function () {
                    var i = $(this);
                    if (i.hasClass("fontColor")) {
                        var vals = $(i).find("input").val();
                        var txt = $(i).text();
                        //alert(txt);
                        $("#showGroupBox").append('<a href="#" class="organizationBtn organizationBtnId' + vals + '">' + txt + '<input type="hidden" value="+"vals"+"></a>');
                    } else {
                        var vals = $(i).find("input").val();
                        $("#showGroupBox").find(".organizationBtnId" + vals + "").remove();
                    }
                });
            });
            /*关闭编辑车站层*/
            $(".closeGroupBoxEdit").click(function () {
                $("#groupBoxEdit").hide();
            });
        })
    });
</script>
</body>
</html>